#define DEBUG
#include <cstdio>
#define MAXN 2500

using namespace std;

int main() {
#ifdef DEBUG
  freopen("1.in", "r", stdin);
  freopen("1.out", "w", stdout);
#endif

  static int a[MAXN+1], div[MAXN+1][MAXN+1];
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i=1; i<=n; i++) {
    scanf("%d", a+i);
    for (int j=1; j<=n; j++) {
      div[j][i] = div[j][i-1]+(a[i]%j==0);
    }
  }

  for (int i=1; i<=m; i++) {
    int l, r;
    long long ans=0;
    scanf("%d %d", &l, &r);
    for (int j=l; j<=r; j++) {
      ans += div[a[j]][r]-div[a[j]][l-1];
    }
    printf("%lld\n", ans);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
